package com.monitor.spring.controller;

import com.monitor.core.annotation.ControllerMonitor;
import com.monitor.core.bean.MessageHanlderType;
import com.monitor.spring.service.TestService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("test")
public class TestController {
    private static Logger logger = Logger.getLogger(TestController.class);
    @Autowired
    TestService testService;

    @RequestMapping("hello")
    @ResponseBody
    @ControllerMonitor(name = "hello测试", handlerType = MessageHanlderType.RabbitMQ)
    public String hello(HttpServletRequest httpServletRequest, @RequestParam("args") String args) {
        logger.info("hello");
        return args;
    }

    @RequestMapping("print")
    @ResponseBody
    @ControllerMonitor(name = "print测试", handlerType = MessageHanlderType.Kafka)
    public String print(HttpServletRequest httpServletRequest, @RequestParam("args") String args) {
        testService.print();
        return "print";
    }
}
